#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	vector<string> codes;
	{
		ifstream fin;
		string strRow;
		fin.open("codes.txt");
		while (getline(fin, strRow))
		{
			codes.push_back(strRow);
		}
		fin.close();
	}

	ofstream fout;
	fout.open("codescomps.txt");
	int num = 0;
	int HD = codes[0].length();
	for (int i = 0; i < codes.size(); i++)
	{
		for (int j = i + 1; j < codes.size(); j++)
		{
			int distance = 0;
			for (int k = 0; k < codes[i].length(); k++)
			{
				if (codes[i][k] != codes[j][k])
				{
					distance++;
				}
			}
			fout << "#" << ++num <<  ": Distance between " << codes[i] << " and " << codes[j] << " is: " << distance << endl;
			if (distance < HD)
			{
				HD = distance;
			}
		}
	}
	fout << endl << "Hamming Distance: " << HD;
	fout.close();
	system("pause");
	return 0;
}